Pipelines

A pipeline is a series of commands connected by pipeline operators (|) (ASCII 124). Each pipeline operator sends the results of the preceding command to the next command.

The output of the first command can be sent for processing as input to the second command. And that output can be sent to yet another command. The result is a complex command chain or pipeline that is composed of a series of simple commands.

In a pipeline, the commands are processed in order from left to right. The processing is handled as a single operation and output is displayed as it's generated.

Command-1 | Command-2 | Command-3

Here is a simple example. The following command gets the Notepad process and then stops it.

Get-Process notepad | Stop-Process

This example shows how to sort all the processes on the computer by the number of open handles in each process

Get-Process | Sort-Object -Property handles

This example shows how to use the Format-List cmdlet to display a list of properties for a process object.

Get-Process winlogon | Format-List -Property *